package main

import (
	"regexp"
)

var (
	ErrPhoneIsRequireMsg = "手机号不能为空"
	ErrPhoneIsNumberMsg  = "手机号必须数字"
	ErrPhoneFormatMsg    = "手机号格式不正确"

	ErrCodeIsRequireMsg = "验证码不能为空"
	ErrCodeIsNumberMsg  = "验证码必须数字"
	ErrCodeLengthMsg    = "验证码必须4位"
)

func isRequire(s string) bool {
	return s == ""
}

func isPhone(s string) bool {
	matched, _ := regexp.MatchString(`^(1[3-9][0-9]\d{8})$`, s)
	return matched
}

func length(s string, value int) bool {
	return len(s) == value
}

func isNumber(s string) bool {
	matched, _ := regexp.MatchString(`^[0-9]+$`, s)
	return matched
}
